#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import csv, io
COLS = ["model","concurrency","accuracy","e2el_avg","e2el_p50","e2el_p90","e2el_p99","ttft_avg","input_tokens_avg","success","fail","total_requests"]
def render_markdown_table(csv_path: str) -> str:
    rows = []
    with open(csv_path, "r", encoding="utf-8") as f:
        r = csv.DictReader(f)
        for row in r:
            rows.append(row)
    out = io.StringIO()
    out.write("| " + " | ".join(COLS) + " |\n")
    out.write("|" + "|".join(["---"]*len(COLS)) + "|\n")
    for row in rows:
        out.write("| " + " | ".join([str(row.get(c,"")) for c in COLS]) + " |\n")
    return out.getvalue()
if __name__ == "__main__":
    import argparse
    ap = argparse.ArgumentParser()
    ap.add_argument("--csv", required=True)
    args = ap.parse_args()
    print(render_markdown_table(args.csv))
